import server from './server';
import { message } from 'antd';
import cookie from 'react-cookies';

server.interceptors.response.use(res => {
    if (res === undefined) {
    }else{
        if (res.data.code === 0) {
            return res.data;
        } else if (res.data.re_login === 1) {
            cookie.remove('station_console_setting_web_login');
            sessionStorage.removeItem('urlConfig');
            message.error(res.data.detail, 2, () => {
                window.location.href = '/login'
            })
        } else {
            message.error(res.data.detail, 1);
        }
    }
})

export default server;
